<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<style>
</style>
<script type="text/javascript">
	/* function complete( flag ) {
		$("#completeFlag").val(flag);
	} */
    $(function() {
        $('#leavehandleForm').form({
            url : '${path}/example/leave/completeTask/${taskId}',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    showMsg(result.msg);
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    var form = $('#leavehandleForm');
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });
    });



</script>
<div class="easyui-layout" data-options="fit:true,border:false" >
    <div data-options="region:'center',border:false" style="overflow-x:hidden;overflow-y: auto;padding: 3px;" >
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-clock icon-blue'" onclick="queryHistoryCommentFun('${leave.processInstanceId}')">历史批注</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-arrow-left icon-blue'" onclick="fallbackFun('${leave.processInstanceId}','${procDefId}','${taskId}','${taskDefKey}')">回退</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-arrow-right icon-blue'" onclick="forwardFun('${leave.processInstanceId}','${procDefId}','${taskId}','${taskDefKey}')">前进</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-comments icon-blue'" onclick="doDelegateTask()">委派</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fi-sound icon-blue'" onclick="doTransferTask();">转办</a>
    	<a href="${ctxPath}/process/graphHistoryProcessInstance?processInstanceId=${leave.processInstanceId}" target="_blank" class="easyui-linkbutton" data-options="iconCls:'fi-photo icon-blue'">查看流程图</a>
    	<a href="javascript:;" target="_blank" class="easyui-linkbutton" data-options="iconCls:'fi-print icon-blue'">打印</a>
        <form id="leavehandleForm" method="post">
        	<input type="hidden" name="id" value="${leave.id }" />
            <table class="grid">
            	<tr>
            		<td style="width:100px;">任务执行人</td>
            		<td>${assigneeOrCandidateUser}</td>
            	<td style="width:100px;">当前任务办理人</td>
            		<td><shiro:principal></shiro:principal></td>
            	</tr>
            	</table>
            	 <table class="grid">
 				<tr>
                     <td style="text-align:right">申请人</td>
                      <td>
                        <input name='userName'   type='text' placeholder='请输入申请人' class='easyui-text-2  span2' value="${leave.userName}" disabled="disabled">
                        <input type="hidden" name="userid" value='${leave.userid}'/>
                     </td>
                  </tr> <tr>
                    <td style="text-align:right">标题</td>
                      <td>
                        <input name='title' id='title'  type='text' placeholder='请输入标题' class='easyui-text-2  span2' style="width:90%" value="${leave.title }" disabled="disabled">
                     </td>
                  </tr><tr>
                     <td style="text-align:right">请假时间</td>
                      <td>
                        <input name='leaveDate' id='leaveDate' type='text'  class='easyui-text-2 easyui-datebox  span2' data-options='' value='${leave.leaveDate }' style='height: 29px;' disabled="disabled">
                     </td>
                     </tr>
                    <tr>
                     <td style="text-align:right">天数</td>
                      <td>
                        <input name='days' id='days'  type='text' placeholder='请输入天数' class='easyui-text-2  span2' value="${leave.days }" disabled="disabled">
                     </td>
                  </tr> 
 				<tr>
                     <td style="text-align:right">请假原因</td>
                      <td>
                        <textarea name="reason" class="easyui-text-2 easyui-validatebox" data-options="required:true" style="height:50px;width:90%" disabled="disabled">${leave.reason }</textarea>
                     </td>
                  </tr> 
                  <tr>
                  <td style="text-align:right">审批意见</td>
                  	<td>
                  		<textarea cols="33" rows="5" name="content" class="easyui-text-2"></textarea><br />
                  		<input type="radio" name="completeFlag"  value="true" class="input_button1" checked="checked"/>同意
            			<input type="radio" name="completeFlag"  value="false" class="input_button1"/>不同意
                  	</td>
                  </tr>
                 <c:if test="${tasks.size()>0}">
                  	<tr>
                  		<td style="text-align:right">下一步</td>
                  		<td>
                  <c:forEach var="task" items="${tasks}">
                  			<b>${task.taskName}：</b>
                  			<input type="hidden" name="${task.taskDefKey}_taskType" value="${task.taskType}"/>
                  			<c:if test="${task.taskType eq 'assignee'}">
                  			 <c:if test="${task.taskDefKey eq 'modifyApply'}">
                  			 <input type="hidden" name="${task.taskDefKey}_candidate_ids"  value="${leave.userid}"/>
                  			 <input type="hidden"  name="${task.taskDefKey}_candidate_name"  value="${leave.userName}">
                  			 ${leave.userName}<br/>
                  			 <c:if test="${taskDefKey eq 'hrAudit'}">
                  			 	<br/><b>结束</b>
                  			 </c:if>
                  			 </c:if>
                  			 <c:if test="${task.taskDefKey !='modifyApply'}">
                  				<input type="hidden" name="${task.taskDefKey}_candidate_ids" id="${task.taskDefKey}_candidate_ids" value="${task.candidate_ids}"/>
                  				<input type="text" class="easyui-text-2" name="${task.taskDefKey}_candidate_name" id="${task.taskDefKey}_candidate_ids_disp" 
                  				onfocus="selectUser(false,'${task.taskDefKey}_candidate_ids','${task.taskDefKey}_candidate_ids_disp')" value="${task.candidate_name}"/>
                  				 </c:if>
                  			</c:if>
                  			<c:if test="${task.taskType eq 'candidateUser'}">
                  				<input type="hidden" name="${task.taskDefKey}_candidate_ids" id="${task.taskDefKey}_candidate_ids" value="${task.candidate_ids}"/>
                  				<input type="text" class="easyui-text-2" name="${task.taskDefKey}_candidate_name" id="${task.taskDefKey}_candidate_ids_disp" 
                  				onfocus="selectUser(true,'${task.taskDefKey}_candidate_ids','${task.taskDefKey}_candidate_ids_disp')" value="${task.candidate_name}"/>
                  			</c:if>
                  			<c:if test="${task.taskType eq 'candidateGroup'}">
									<input type="hidden" name="${task.taskDefKey}_candidate_ids"
										id="${task.taskDefKey}_candidate_ids" />
									<input type="text" class="easyui-text-2"
										name="${task.taskDefKey}_candidate_name"
										id="${task.taskDefKey}_candidate_ids_disp"
										value="${task.candidate_ids}"
										onfocus="selectRole(true,'${task.taskDefKey}_candidate_ids','${task.taskDefKey}_candidate_ids_disp')"
										value="${task.candidate_name}" />
								</c:if>
                  			<br /><br />
                  </c:forEach>
                 
                  		</td>
                  	</tr>
                  	</c:if>
                  <c:if test="${comments.size()>0 }">
                  <tr>
                  	<td style="text-align:right">
                  		历史批注
                  	</td>
                  	<td>
                  		<c:forEach var="comment" items="${comments}">
                  			<p><b>任务名称：${comment.taskName}</b></p>
                  			<p>评论人：${comment.userName}</p>
                  			<p>评论时间：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${comment.time}"/></p>
                  			<p>评论内容：${comment.comment}</p>
                  		</c:forEach>
                  	</td>
                  </tr>
                  </c:if>
            </table>
        </form>
    </div>
</div>